﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace Test
{
    public partial class frmPFD : Form
    {
        public frmPFD()
        {
            InitializeComponent();

            primaryFlightDisplay1.Altitude = 70000;
            primaryFlightDisplay1.HeightFromGround = 500;
        }

        private void trbHeading_Scroll(object sender, EventArgs e)
        {
            primaryFlightDisplay1.Heading = trbHeading.Value/10.0f;
        }

        private void trbAirSpeed_Scroll(object sender, EventArgs e)
        {
            primaryFlightDisplay1.AirSpeed = trbAirSpeed.Value;
        }

        private void trbSetSpeed_Scroll(object sender, EventArgs e)
        {
            primaryFlightDisplay1.DestinationAirSpeed = trbSetSpeed.Value;
        }

        private void trbAltitude_Scroll(object sender, EventArgs e)
        {
            primaryFlightDisplay1.Altitude = trbAltitude.Value;
        }

        private void trbSetAltitude_Scroll(object sender, EventArgs e)
        {
            primaryFlightDisplay1.DestinationAltitude = trbSetAltitude.Value;
        }

        private void trbGroundAltitude_Scroll(object sender, EventArgs e)
        {
            //primaryFlightDisplay1.GroundAltitude = trbGroundAltitude.Value;
        }

        private void trbSinkRate_Scroll(object sender, EventArgs e)
        {
            primaryFlightDisplay1.VerticalSpeed = trbSinkRate.Value;
        }

        private void trbBank_Scroll(object sender, EventArgs e)
        {
            primaryFlightDisplay1.Bank = trbBank.Value;
        }

        private void trbPitch_Scroll(object sender, EventArgs e)
        {
            primaryFlightDisplay1.Pitch = trbPitch.Value;
        }

        private void frmPFD_Load(object sender, EventArgs e)
        {

        }

        private void trbWarnAltitude_Scroll(object sender, EventArgs e)
        {
            primaryFlightDisplay1.DangerHeight = trbWarnAltitude.Value;
        }

        private void trbDistanceToGround_Scroll(object sender, EventArgs e)
        {
            primaryFlightDisplay1.HeightFromGround = trbDistanceToGround.Value;
        }

        int dir = -1;
        private void timer1_Tick(object sender, EventArgs e)
        {
            primaryFlightDisplay1.Altitude += dir;
            primaryFlightDisplay1.HeightFromGround += dir;
            if (primaryFlightDisplay1.HeightFromGround == 0)
                dir = 1;
            //primaryFlightDisplay1.GroundAltitude = primaryFlightDisplay1.Altitude - primaryFlightDisplay1.HeightFromGround / 100;
        }

        private void roundTuner1_ValueChanged(object sender)
        {
            segSevenDisplay1.Value = (roundTuner1.Value / 10.0).ToString("f1");
        }

        private void checkBox1_CheckedChanged(object sender, EventArgs e)
        {
            if (checkBox1.Checked)
                watch1.StartTimer();
            else
                watch1.StopTimer();
        }

        private void radioButton1_CheckedChanged(object sender, EventArgs e)
        {
            if(radioButton1.Checked)
                watch1.SetMode(Walson.Form.FlightInstrument.Watch.Mode.Watch);
        }

        private void radioButton2_CheckedChanged(object sender, EventArgs e)
        {
            if (radioButton2.Checked)
                watch1.SetMode(Walson.Form.FlightInstrument.Watch.Mode.Timer);
        }

        private void checkBox2_CheckedChanged(object sender, EventArgs e)
        {
            roundCompass1.CenterRotate=checkBox2.Checked;
        }

        private void trackBar1_Scroll(object sender, EventArgs e)
        {
            roundCompass1.Heading = trackBar1.Value;
        }

        private void checkBox3_CheckedChanged(object sender, EventArgs e)
        {
            DotLedDisplay1.Animation = checkBox3.Checked;
        }

        private void lightButton1_Click(object sender, EventArgs e)
        {
            lightText1.On = !lightText1.On;

//             if (lightButton1.Clicked)
//             {
//                 lightButton1.TextForeColor = Color.Red;
//                 lightButton1.TextBackColor = Color.Red;
//                 lightButton1.Alpha = 16;
//                 lightButton1.Blur = 7;
//             }
//             else
//             {
//                 lightButton1.TextForeColor = Color.Maroon;
//                 lightButton1.TextBackColor = Color.Maroon;
//                 lightButton1.Alpha = 0;
//                 lightButton1.Blur = 5;
//             }
        }

        private void trbBat_Scroll(object sender, EventArgs e)
        {
            battery1.Value = trbBat.Value;
            battery2.Value = trbBat.Value;
        }

        private void trbPie_Scroll(object sender, EventArgs e)
        {
            pieMeter1.Value = trbPie.Value;
        }

        private void lightText1_StateChanged(object sender, EventArgs e)
        {
            if (lightText1.On)
                watch1.StartTimer();
            else
                watch1.StopTimer();
        }
    }
}
